package com.openapi.service;

import com.openapi.data.Session;
import com.openapi.data.SessionType;
//import com.sun.org.apache.regexp.internal.RE;
import org.apache.commons.collections4.Get;
import org.hibernate.tool.schema.internal.exec.GenerationTarget;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SessionManagerFactory {
    private static Map<SessionType, SessionManager> map = new HashMap<>();
    static {
        map.put(SessionType.JT_808,new SessionManager());
        map.put(SessionType.HJ_212,new SessionManager());
    }
    public static SessionManager GetSessionManager(SessionType sessionType){
        if(map.containsKey(sessionType))return map.get(sessionType);
        return null;
    }
    public static Session removeBySessionId(String channelId){
        for (SessionManager sessionManager :map.values()){
            Session temp = sessionManager.removeBySessionId(channelId);
            if(temp!=null)return temp;
        }
        return null;
    }

}
